<?php
class SeoHelper extends AppHelper {

	/**
	 * Fix SQL Injection
	 */

	public $helpers=array('Common');

	public function link($url=null,$isSiteUrl=true){
		$returnUrl='';
		if(!Configure::read('SEO'))
    		$returnUrl=$url;
		else{
 			App::uses('CommonComponent', 'Controller/Component');
	    	$Common=& new CommonComponent(new ComponentCollection());
			$friendlyUrls=$Common->getCacheRoute();
			if(!empty($friendlyUrls)){
				$returnUrl=array_search($url, $friendlyUrls);
				if(empty($returnUrl))$returnUrl=$url;
			}
		}
		if($isSiteUrl)$returnUrl=SITE_URL.$returnUrl;
		return $returnUrl;
	}
}
?>
